Lesson 7 - intermediate exercise

For each scenario write code to solve it.

Scenario - Create a simple binary calculator. It will add two binary values together and output the result. A sample run is shown below -

Enter number 1 - 10110011
Enter number 2 - 00010011
result - 11000110 .

Toggle answer

Scenario - You have been given a large amount of coins in a black bag. You have been asked to work out what the minimum and maximum value could be by weighing the coins. You are not allowed to open the black bag!! Below is a table of coins which could be in the bag (these are made up weights!). The input will be given in grams.

Amount Weight
1p 6g
2p 12g
10p 9g
20p 7g

 

Toggle answer